package lesson08;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.InputMismatchException;
import java.util.Scanner;

public class Test01 {
    public void a() throws LovoException{
        System.out.println("进入方法a");
        b();
        System.out.println("退出方法a");
    }
    public void b() throws LovoException{
        System.out.println("进入方法b");
        c();
        System.out.println("退出方法b");
    }
    public void c() throws LovoException{
        System.out.println("进入方法c");
        d();


        System.out.println("退出方法c");
    }
    public void d() throws LovoException{
        System.out.println("进入方法d");
        try{
            String str = null;
//            System.out.println(str.toString());
//            int a = 100/0;
            int [] ary = new int[5];
            ary[5] = 100;

        }catch (NullPointerException e){
            throw new LovoException(1000,"空指针异常");
        }catch(ArithmeticException e){
            throw new LovoException(1001,"除0异常");
        }catch(Exception e){
            throw new LovoException(1999,"未知错误");
        }finally{
            System.out.println("finally");
        }
        System.out.println("退出方法d");
    }

    public static void main(String[] args) {
        Test01 test01 = new Test01();
        try{
            test01.a();
        }catch (LovoException e){
            System.out.println(e.getMessage());
        }

        System.out.println(LocalDateTime.parse("2012-12-05T13:23:40").format(DateTimeFormatter.ofPattern("MM/dd E")));
        System.out.println(LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy/MM/dd")));
    }
}
